Compile C, C++, or Objective C

Contents|Index|Previous|Next
Compile C, C++, or Objective C

The C, C++, and Objective C versions of the compiler are integrated; the GNU C compiler can compile programs written in C, C++, or Objective C.

“gcc” is a common shorthand term for the GNU C compiler. This is both the most general name for the compiler, and the name used when the emphasis is on compiling C programs.

When referring to C++ compilation, it is customary to call the compiler g++. Since there is only one compiler, it is also accurate to call it gcc, no matter what the language context; however, the term, g++, is more useful when the emphasis is on compiling C++ programs.

We use the name GNU CC to refer to the compilation system as a whole, and more specifically to the language-independent part of the compiler. For example, we refer to the optimization options as affecting the behavior of GNU CC, or sometimes as affecting just the compiler.

Front ends for other languages, such as Ada 9X, Fortran, Modula-3, and Pascal, are under development. These front-ends, like that for C++, are built in subdirectories of GNU CC and link to it. The result is an integrated compiler that can compile programs written in C, C++, Objective C, or any of the languages for which you have installed front ends.

In the Using GNU CC documentation, we only discuss the options for the C, Objective C, and C++ compilers, and those of the GNU CC core. Consult the documentation of the other front ends for the options to use when compiling programs written in other languages.

g++ is a compiler, not merely a preprocessor. g++ builds object code directly from your C++ program source. There is no intermediate C version of the program. (By contrast, for example, some other implementations use a program that generates a C program from your C++ source.) Avoiding an intermediate C representation of the program means that you get better object code, and better debugging information. The GNU debugger, GDB, works with this information in the object code to give you comprehensive C++ source-level editing capabilities (see “C and C++” in Debugging with GDB in GNUPro Debugging Tools).

Top|Contents|Index|Previous|Next